<template>
    <div id="agreement">
        <van-skeleton title :row="15" :loading="loading">
            <div v-html="content" v-if="content != ''"></div>
            <div v-else>
                <van-empty description="暂无内容" />
            </div>
        </van-skeleton>
    </div>
</template>

<script>
    import { Toast } from 'vant';
    import router from '@/router';
    export default {
        props: [], // 父辈向子辈传参
        name: 'agreement',
        components: { // 组件的引用

        },
        data() {
            return {
                content: '',
                loading: true
            }
        },
        methods: {},
        computed: {},
        watch: {},
        created() { },
        mounted() {
            // this.content = data.agreementText
            let textType = this.$route.params.textType
            console.log("this", textType);
            // let res = {
            //     data: null
            // }
            // if (res.data?.agreement_text) {
            //     this.content = res.data.agreement_text
            //     this.loading = false
            // } else {
            //     Toast('暂未配置该协议')
            //      this.loading = false
            //     setTimeout(() => {
            //         router.go(-1)
            //     }, 900)
            // }

            // return
            this.$api.app.agreementApi({
                textType
            }).then((res) => {
                console.log("协议", res);
                if (res.data?.agreement_text) {
                    this.content = res.data.agreement_text
                    this.loading = false
                } else {
                    Toast('暂未配置该协议')
                    this.loading = false
                    setTimeout(() => {
                        router.go(-1)
                    }, 900)
                }
            }).catch((err) => {
                console.log("err", err);
                Toast(err.message)
            });
        },
    }
</script>
    
<style scoped lang='scss'>
    #agreement {
        padding: 16px 10px 24px;
        background-color: #fff;
        min-height: 100vh;
        box-sizing: border-box;
        font-size: 16px;
    }
</style>